﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MeTalker.BLL;
using MeTalker.Model;

public partial class Default_index : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //string d = GetMD5("jinlansoft2010");
        Session["UserSession"] = null;
        SetClientCookies(null);
        //if (GetClientCookies() != null)
        //    Response.Redirect("Main.aspx");
    }


    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(txtUserName.Text))
        {
            Alert("用户名不能为空!");
            return;
        }

        if (string.IsNullOrEmpty(txtPassword.Text))
        {
            Alert("密码不能为空!");
            return;
        }

        UsersMod user = UsersBLL.SignUser(new UsersMod() { UserName = txtUserName.Text, Password = GetMD5(txtPassword.Text) });
        if (user != null)
        {
            //Session["UserSession"] = user;
            SetClientCookies(user);
            Response.Redirect("Main.aspx");
        }
        else
        {
            Alert("登录失败! 用户或密码不正确!");
        }
    }
}